package top.yxqz.spring.aop.xml;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author: 余小小
 * @date: 2023/4/14
 * @description：日志切面类
 * @Aspect：切面，用了它，spring就会把它认为是一个切面 通知的种类：
 */
public class CalculatorLoggerAspectXML {

    public void beforeAdviceMethod() {
        System.out.println("1.前置通知——beforeAdviceMethod");
    }

    public void afterAdviceMethod() {
        System.out.println("2.后置通知——afterAdviceMethod");
    }

    public void afterReturningAdviceMethod(int returnValue) {
        System.out.println("3.返回通知——afterReturningAdviceMethod");
        System.out.println("目标方法的返回值是：" + returnValue);
    }
    public void afterThrowingAdviceMethod(Exception exception) {
        System.out.println("4.异常通知——afterThrowingAdviceMethod");
        System.out.println("异常信息是：" + exception.getMessage());
    }

    public Object aroundAdviceMethod(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("5.环绕通知——aroundAdviceMethod");
        Object proceed = joinPoint.proceed();
        return proceed;
    }
}
